package com.homework8_3;

public class News implements Comparable {

    private int num;
    private String title;
    private String content;
    private int hits;

    public News(int num, String title, String content, int hits) {
        this.num = num;
        this.title = title;
        this.content = content;
        this.hits = hits;
    }

    public News() {
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getHits() {
        return hits;
    }

    public void setHits(int hits) {
        this.hits = hits;
    }

    public  int compareTo(Object obj){
        News news=(News)obj;
        if (this.hits>news.getHits()){
            return 1;
        }else if (this.hits<news.getHits()){
            return -1;
        }
        return 0;
    }
}
